/**
 * 
 * @author danielshalev
 *
 */
public class Runner extends ComputerControlled {
	
	/**
	 * construct a new runner SpaceShip.
	 */
	public Runner() {
		super();
	}

	@Override
	public void doAction(SpaceWars game) {
		this.runFromSpaceShip(game);
		
		//pointer to closest ship
		SpaceShip nearShip=game.getClosestShipTo(this);
		
		this.turnShieldOff();
		
		//the angle from nearest ship
		double nearAngle=Math.abs(nearShip.getPhysics().angleTo(this.getPhysics()));
		
		//the distance from nearest ship
		double nearDistance=nearShip.getPhysics().distanceFrom(this.getPhysics());
		
		if(nearDistance<=CLOSEST_SHIP_CONDITION && nearAngle<=CLOSEST_SHIP_CONDITION){
			this.teleport();
		}
		
		//the ship is regaining energy every round
		this.setEnergy(REGAINED_ENERGY);
	}

}
